package javaBase.javaInnerClass;

/**
 * Created by Administrator on 2017/2/22 0022.
 */
public class OuterClass02 {
    private String str;

    public void outerDisplay() {
        System.out.println("outerClass...");
    }

    public class InnerClass {
        public void innerDisplay() {
//使用外围内的属性
            str = "chenssy...";
            System.out.println(str);
//使用外围内的方法
            outerDisplay();
        }
    }

    /*推荐使用getxxx()来获取成员内部类，尤其是该内部类的构造函数无参数时 */
    public InnerClass getInnerClass() {
        return new InnerClass();
    }

    public static void main(String[] args) {
        OuterClass02 outer = new OuterClass02();
        OuterClass02.InnerClass inner = outer.getInnerClass();
        inner.innerDisplay();
    }
}
